from config.all_paths import allure_report_html


def set_windows_title(new_title):
    """
    修改Allure报告的浏览器窗口标题文案Allure Report为自定义的名称
    """
    # allure报告的html文件地址
    title_filepath = allure_report_html
    with open(title_filepath, 'r+', encoding="utf-8") as f:
        # 读取当前文件的所有内容
        all_the_lines = f.readlines()
        f.seek(0)
        f.truncate()
        # 循环遍历每一行的内容，将Allure Report全部替换为new_title(新文案)
        for line in all_the_lines:
            f.write(line.replace("Allure Report", new_title))
        # 关闭文件
        f.close()



if __name__ == '__main__':
    set_windows_title('自动化测试报告')